<?php 
$templateURL = $this->basePath('public/template');
?>
<div class="panel panel-default">
				  <!-- Default panel contents -->
				  <div class="panel-heading panel-heading1"><h1><?php echo $this->escapeHtml('Sản phẩm'); ?>(<?= $this->allRecord ?>)</h1>
					  <div id="addsp">
							   <a href="#" class="btn btn-danger deleteall"><i class="fa fa-trash-o"></i>
							  Xoá sản phẩm</a>
							  <input type="hidden" name="delete" id="deleteall" value="<?php echo $this->url('product/default', array('action'=>'deleteall','id' => ''));?>">
							  <a href="<?php echo $this->url('add');?>" class="btn btn-primary"><i class="fa fa-plus-circle"></i>
							  Thêm sản phẩm</a>
					  </div>
					  <?php
					    $form = $this->SearchForm;
					    $form->prepare();
					    echo $this->form()->openTag($form);
					    ?>	
					  <ul id="search1">
					    <li>
					      
						</li>
						<li>	
						  	<div class="navbar-form navbar-left">				
						        <div class="form-group search3">
						         <?php echo $this->formElement($form->get('nameprosearch')); ?>
						        </div>
						        <?php echo $this->formElement($form->get('search')); ?>
							 </div> 
							 <span class="text-danger product-error"><?php echo $this->formElementErrors($form->get('nameprosearch'));?></span>
							</li>
					  </ul>
					<?php
					      echo $this->form()->closeTag($form);
					     ?>
				  </div>
					  <!-- Table -->
				  <table class="table table-striped">
				    <tr><th><label class="checkbox-custom" data-initialize="checkbox">
				        <input type="checkbox" class="ckeck" name="ckeck">
				    </label></th>
                   <th>ID</th><th>ẢNH</th><th>TÊN SẢN PHẨM</th><th>NGÀY ĐĂNG</th><th>NỔI BẬT</th><th>HÀNH ĐỘNG</th></tr>
                   <?php foreach ($this->product as $product) : ?>
				    <tr>
				    <td><label class="checkbox-custom" data-initialize="checkbox">
				        <input type="checkbox" class="ckecks" name="ckeck[]" value="<?= $product['ID_PR'] ?>">
				    </label></td>
				    
				    <td><?php echo $this->escapeHtml($product['ID_PR']);?></td>
				    <td><img width="120" height="100" src="<?php echo '/timthumb/120x100/'.$this->escapeHtml($product['LINKIMG']);?>"></td>
				    <td><a href="#"><?php echo $this->escapeHtml($product['NAME_PR']);?></a></td>
				    <td><?php echo $this->escapeHtml($product['DATE_PR']);?></td>
				    <td><span class="Status">
				    <a href="<?php echo $this->url('product/default', array('action'=>'highlights','id' => $product['ID_PR']),array(
					        'query' => array(
					            'noibat' => $product['HIGHLIGHT_PR'],
					        )
                           ));?>">
				    <i class="fa <?= $product['HIGHLIGHT_PR'] == 'yes'? 'fa-toggle-on':'fa-toggle-off' ?>"></i></a>
				    </span>
				    </td>
				    <td class="action">
                    <div class="btn-group">
					  <button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown">
					    Action <span class="caret"></span>
					  </button>
					  <ul class="dropdown-menu" role="menu">
					    <li><a href="<?php
						    $str = $product['NAME_PR'];
					      	$str = preg_replace("/(à|á|ạ|ả|ã|â|ầ|ấ|ậ|ẩ|ẫ|ă|ằ|ắ|ặ|ẳ|ẵ)/", 'a', $str);
							$str = preg_replace("/(è|é|ẹ|ẻ|ẽ|ê|ề|ế|ệ|ể|ễ)/", 'e', $str);
							$str = preg_replace("/(ì|í|ị|ỉ|ĩ)/", 'i', $str);
							$str = preg_replace("/(ò|ó|ọ|ỏ|õ|ô|ồ|ố|ộ|ổ|ỗ|ơ|ờ|ớ|ợ|ở|ỡ)/", 'o', $str);
							$str = preg_replace("/(ù|ú|ụ|ủ|ũ|ư|ừ|ứ|ự|ử|ữ)/", 'u', $str);
							$str = preg_replace("/(ỳ|ý|ỵ|ỷ|ỹ)/", 'y', $str);
							$str = preg_replace("/(đ)/", 'd', $str);
							$str = preg_replace("/(À|Á|Ạ|Ả|Ã|Â|Ầ|Ấ|Ậ|Ẩ|Ẫ|Ă|Ằ|Ắ|Ặ|Ẳ|Ẵ)/", 'A', $str);
							$str = preg_replace("/(È|É|Ẹ|Ẻ|Ẽ|Ê|Ề|Ế|Ệ|Ể|Ễ)/", 'E', $str);
							$str = preg_replace("/(Ì|Í|Ị|Ỉ|Ĩ)/", 'I', $str);
							$str = preg_replace("/(Ò|Ó|Ọ|Ỏ|Õ|Ô|Ồ|Ố|Ộ|Ổ|Ỗ|Ơ|Ờ|Ớ|Ợ|Ở|Ỡ)/", 'O', $str);
							$str = preg_replace("/(Ù|Ú|Ụ|Ủ|Ũ|Ư|Ừ|Ứ|Ự|Ử|Ữ)/", 'U', $str);
							$str = preg_replace("/(Ỳ|Ý|Ỵ|Ỷ|Ỹ)/", 'Y', $str);
							$str = preg_replace("/(Đ)/", 'D', $str);
							
					        $str = strtolower(preg_replace(array('/[^a-zA-Z0-9 -]/', '/[ -]+/', '/^-|-$/'),
                             array('', '-', ''), $str));
								      
					      echo  $this->url('product/default',array('action'=>'edit', 'id' => $product['ID_PR'])).'-'.$str.'.html';
					      ?>"><i class="fa fa-pencil"></i>EDIT</a>
                          
                           </li>
					    <li><a href="#" class="delete" id="<?= $product['ID_PR'] ?>"><i class="fa fa-trash-o"></i>DELETE</a></li>
					  </ul>
					  <input type="hidden" value="<?php echo $this->url('product/default',
                           array('action'=>'delete', 'id' => $product['ID_PR']));?>" id="urldelete<?= $product['ID_PR'] ?>"/>
					</div>
                    </td></tr>
                     <?php endforeach; ?>
				  </table>
				  <div class="shows">
				    showing <?= (int)$this->offset+1 < (int)$this->allRecord?(int)$this->offset+1:(int)$this->allRecord ?> to <?= (int)$this->offset+10 < (int)$this->allRecord?(int)$this->offset+10:(int)$this->allRecord?> of <?= $this->allRecord ?> entries
				  </div>
				   <?php
		            echo $this->paginationControl($this->paginator, 'sliding', 'layout/paginator', array('route' => 'product/default','search_by'=>$this->search_by));
		            ?>
				</div>